/*
 * Copyright (c) 2025 李伟国
 * SQL-API is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package com.moyu.sql.core.engine;

import org.apache.ibatis.exceptions.TooManyResultsException;
import org.apache.ibatis.mapping.SqlCommandType;

import java.util.Map;

public interface MoyuSqlSession {

    /**
     * 添加映射
     *
     * @param sqlId          sqlId
     * @param sqlTemplate    sql语句
     * @param sqlCommandType sql命令类型
     */
    void addMappedStatement(String sqlId, String sqlTemplate, SqlCommandType sqlCommandType);

    /**
     * 更新MappedStatement
     *
     * @param sqlId          sqlId
     * @param sqlTemplate    sql语句
     * @param sqlCommandType sql命令类型
     */
    void updateMappedStatement(String sqlId, String sqlTemplate, SqlCommandType sqlCommandType);

    /**
     * 执行列表查询 sql
     *
     * @param sqlId     sqlId
     * @param paramsMap 参数
     * @return 查询列表
     */
    <E> java.util.List<E> selectList(String sqlId, Map<String, Object> paramsMap);

    /**
     * 执行插入 sql
     *
     * @param sqlId     sqlId
     * @param paramsMap 参数
     * @return 插入数量
     */
    int insert(String sqlId, Map<String, Object> paramsMap);

    /**
     * 执行更新 sql
     *
     * @param sqlId     sqlId
     * @param paramsMap 参数
     * @return 更新数量
     */
    int update(String sqlId, Map<String, Object> paramsMap);

    /**
     * 执行删除 sql
     *
     * @param sqlId     sqlId
     * @param paramsMap 参数
     * @return 删除数量
     */
    int delete(String sqlId, Map<String, Object> paramsMap);

    /**
     * 执行查询 sql
     *
     * @param sqlId     sqlId
     * @param paramsMap 参数
     * @return 查询结果
     */
    <T> T selectOne(String sqlId, Map<String, Object> paramsMap) throws TooManyResultsException;
}
